<button onclick="svc_connectPlatform()"> connect</button>
<button onclick="svc_send('hello, websocket')"> send</button>
<script>

    function svc_connectPlatform() {
        //alert("");
        var wsServer = 'ws://192.168.189.128:9096/';
        try {
            svc_websocket = new WebSocket(wsServer);
        } catch (evt) {
            console.log("new WebSocket error:" + evt.data);
            svc_websocket = null;
            if (typeof(connCb) != "undefined" && connCb != null)
                connCb("-1", "connect error!");
            return;
        }
        //alert("");
        svc_websocket.onopen = svc_onOpen;
        svc_websocket.onclose = svc_onClose;
        svc_websocket.onmessage = svc_onMessage;
        svc_websocket.onerror = svc_onError;
    }


    function svc_onOpen(evt) {
		console.log("Connected to WebSocket server.");
    }


    function svc_onClose(evt) {
        console.log("Disconnected");
    }


    function svc_onMessage(evt) {
        alert('Retrieved data from server: ' + evt.data);
    }


    function svc_onError(evt) {
        console.log('Error occured: ' + evt.data);
    }


    function svc_send(msg) {
        if (svc_websocket.readyState == WebSocket.OPEN) {
            svc_websocket.send(msg);
        } else {
            console.log("send failed. websocket not open. please check.");
        }
    }
</script>